<?php

class Model_Vote_Item extends PhalApi_Model_NotORM {


    public function set($item, $userLimit, $nomineeLimit, $startTime, $endTime, $id) {
        return $this->getORM()
            ->where('id', $id)
            ->update([
                "item"         => $item,
                "userLimit"    => $userLimit,
                "nomineeLimit" => $nomineeLimit,
                "startTime"    => $startTime,
                "endTime"      => $endTime,
            ]);
    }

    public function add($data) {
        return $this->getORM()
            ->insert($data);
    }

    public function hasItem($item) {
        return $this->getORM()
            ->where(["item" => $item])
            ->count("id");
    }

    public function itemInfo($id) {
        return $this->getORM()
            ->where(["id" => $id])
            ->fetch();
    }

    public function itemlist() {
        return $this->getORM()
            ->fetchAll();
    }

    public function itemDelete($id) {
        return $this->getORM()
            ->where(["id" => $id])
            ->delete();
    }

    protected function getTableName($id) {
        return 'votes_Items';
    }
}
